layui.use(['table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    /**
     * 管理
     */
    var Product = {
        tableId: "salesListTable"
    };

    /**
     * 初始化表格的列
     */
    Product.initColumn = function () {
        return [[
            {type: 'checkbox'},
            {field: 'productId', hide: true, title: '主键'},
            {field: 'productName', hide: true, title: '产品'},
            {field: 'productModelName', sort: true, title: '产品型号'},
            {field: 'productOrderName', sort: true, title: '产品编号'},
            {field: 'color', sort: true, title: '产品颜色'},
            {field: 'colorNumber', sort: true, title: '产品色号'},
            {field: 'material', sort: true, title: '产品材质'},
            {field: 'unitVolume', sort: true, title: '单台体积'},
            {field: 'unitWeight', sort: true, title: '单台净重'},
            {field: 'uniformSalesPrice', sort: true, title: '全国统一价格'},
            {field: 'minSellingPrice', sort: true, title: '最低销售价'},
            {field: 'conversionRatio', sort: true, title: '换算比率'}
        ]];
    };

    /**
     * 点击查询按钮
     */
    Product.search = function () {
        var queryData = {};
        queryData['condition'] = $("#condition").val();
        table.reload(Product.tableId, {where: queryData});
    };


    // var $ = layui.$, active = {
    //     getCheckData: function(){ //获取选中数据
    //         var checkStatus = table.checkStatus('productTable')
    //             ,data = checkStatus.data;
    //         layer.alert(JSON.stringify(data));
    //     }
    // };

    $("#getProductList").click(function () {
        var checkStatus = table.checkStatus('salesListTable'),
            data = checkStatus.data;
        for (var i = 0; i < data.length; i++) {
            data[i].unitsName = "请选择单位";
            data[i].price = "请填写单价";
            data[i].remark = "";
            data[i].orderNumbers = "请填写购买数量";
            data[i].channelName = "请选择渠道";
            data[i].packageSize = "请选择包装尺寸";
            data[i].orderNumbers = 0;
        }
        admin.putTempData("sales_list", data);
        admin.closeThisDialog();
        // layer.alert(JSON.stringify(data));
    });


    // 渲染表格
    var tableResult = table.render({
        elem: '#' + Product.tableId,
        url: Feng.ctxPath + '/productOrder/salsOrderList',
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        cols: Product.initColumn()
    });


    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        Product.search();
    });




});
